/*
 * page format:
 *	+------------------------------+
 * ino	| n | keyoff | datoff | keyoff |
 * 	+------------+--------+--------+
 *	| datoff | - - - ---->	       |
 *	+--------+---------------------+
 *	|	 F R E E A R E A       |
 *	+--------------+---------------+
 *	|  <---- - - - | data          |
 *	+--------+-----+----+----------+
 *	|  key   | data     | key      |
 *	+--------+----------+----------+
 * 
 * calculating the offsets for free area:  if the number
 * of entries (ino[0]) is zero, the offset to the END of
 * the free area is the block size. Otherwise, it is the
 * nth (ino[ino[0]]) entry's offset.
 */

int xp_dbm_put_pair_into_page (
	xp_byte_t* page, xp_dbm_datum_t* key, xp_dbm_datum_t* value)
{
	int n;
	xp_uint16_t* pg = (xp_uint16_t*)page;

	n = pg[0];
	offset = (n == 0)? pg[n]: XP_DBM_PAGE_BLOCK_SIZE;

	offset -= key->size;
	xp_memcpy (page + offset, key->data, key->size);

	offset -= value->size;
	xp_memcpy (page + offset, value->data, value->size);

	pg[n + 2] = offset;
	pg[0] += 2;	
}

int xp_dbm_split_page (xp_byte_t* page, xp_byte_t* new)
{
}
